<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>关注列表页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/user_list.css">
</head>
<body>
    <div class="nav">
        <img id = "logo" src="img/logo.png" alt="">
        <span class="title">我的博客系统</span>
        <!--用于占位-->
        <span class="spacer"></span>
        <!--按钮-->
        <a href="blog_list.html"><img src="img/home.png" alt="">主页</a>
        <a href="blog_edit.html"><img src="img/edit.png" alt="">写博客</a>
        <a href="logout"><img src="img/zhuxiao.png" alt="">注销</a>
        <script src="js/jquery.min.js"></script>
        <script src="js/app.js"></script>
     </div>

     <div class="container">
        <div class="user-list">
            
        </div>
     </div>
     <script>
        function getUsers() {
            $.ajax({
                type:'get',
                url:'userlist'+location.search,
                success:function(body) {
                    let userList = document.querySelector('.user-list');
                    for(let user of body) {
                        //创建row
                        let row = document.createElement('div');
                        row.className = 'row';
                        //创建img
                        let img = document.createElement('img');
                        img.src = "img/profile_pic.jpg";
                        row.appendChild(img);
                        //创建username
                        let username = document.createElement('div');
                        username.className = 'username';
                        username.innerHTML = "username: " + user.username;
                        row.appendChild(username);
                        //创建showBlogs
                        let showBlogs = document.createElement('a');
                        showBlogs.href = 'user_bloglist.html?userId=' + user.userId;
                        showBlogs.innerHTML = "查看文章";
                        row.appendChild(showBlogs);

                        userList.appendChild(row)
                    }
                },
                error:function(body) {
                    window.location.href="login.html";
                }
            })
        }
        getUsers();
        checkLogin();
     </script>
</body>
</html>